import paramiko

def sshFileOP():
    #与服务器创建ssh链接
    ssh_conn=paramiko.Transport(("10.4.7.24",22))
    ssh_conn.connect(username="root",password="1")

    #基于上述ssh链接创建ftp客户端ftp_client
    ftp_client=paramiko.SFTPClient.from_transport(ssh_conn)

    #下载文件
    ftp_client.get("/etc/fstab",r"/home/SENSETIME/liangchen.vendor/git/liangchen_test/paramiko/data/fstab")

    #上传文件
    ftp_client.put(r"/home/SENSETIME/liangchen.vendor/git/liangchen_test/paramiko/knows_host路径截图.png","/tmp/knows_host路径截图.png")

    #下载完成后关闭链接
    ssh_conn.close()

if __name__ == '__main__':
    sshFileOP()